package mysgoog.bot;

import java.io.IOException;
import java.util.*;

import mysgoog.board.*;
import mysgoog.gtp.*;
import mysgoog.pattern.StartGame.*;
import mysgoog.pattern.Storage.*;
import mysgoog.util.*;

/**
 * @author Fu, Zhongyang
 */
public class PatternTestBot extends GoBot
{
    private Board board;

    @Override
    public void setBoard(Board board)
    {
        this.board = board;
    }
    @Override
    public Vertex genMove(Color color)
    {
        if (board.getTurn() >= board.BOARD_ELEMNUM)
            return new Vertex("pass");
        while (true)
        {
            PatternBot pattern = new PatternBot();
            List<VertexValue> moves = pattern.genMove(board, color);
            int x = Lib.random(board.BOARD_LENGTH);
            int y = Lib.random(board.BOARD_LENGTH);
            if (moves.size() > 0)
            {
                x = moves.get(0).vertex.x;
                y = moves.get(0).vertex.y;
            }
            if (board.isLegal(color, board.makePos(x, y)))
            {
                return new Vertex(x, y);
            }
        }
    }
}
